import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'

Vue.use(Vuex)



const list = new Vuex.Store({
    state: {
        productList:[],
        barcodeIdList:[]
    },
    mutations: {
        copyProductList(state,cont){
            //单一的改变某一个变量
   
            state.productList = cont;
        },
		
		copyBarcodeIdList(state,cont){
		    //单一的改变某一个变量
		 
		    state.barcodeIdList = cont;
		},
		
        change(state,contObj){
            //通过传入的变量去改变对应的全局变量
            let str = contObj.str;
            let cont = contObj.cont;
            state[str] = cont;
        },
    },
    actions:{
        copeFun:function(context,mData){
            context.commit('copyProductList',mData)
        },
		
		copeFun1:function(context,mData){
		    context.commit('copyBarcodeIdList',mData)
		},
		
        changeFun:function(context,obj){
            context.commit('change',obj)
        }
    }
})

export default list
